﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Smart.Data
{
    /// <summary>
    /// Access 97-2003 访问接口
    /// 默认访问系统根目录下 dbdemo.mdb
    /// </summary>
    public class AccessDataSource : DataSource
    {
        public AccessDataSource()
            : this(
                System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "dbdemo.mdb")) { }
        
        /// <summary>
        /// 
        /// </summary>
        /// <param name="model">数据库路径</param>
        public AccessDataSource(string model)
        {
            Model = model;
            Provider = "System.Data.OleDb";
            FormatString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Persist Security Info=True;";
        }

        public override string ToConnectionString()
        {
            if (string.IsNullOrEmpty(Password))
                return string.Format(FormatString, Model);
            return string.Format(FormatString, Model) + "Jet OLEDB:Database Password=" + Password + ";";
        }
    }
}
